/*
1. Write the code that declares a class called Employee with these data members: 
age, yearsOfService, and Salary.


2. Rewrite the Employee class to make the data members private, and provide public 
accessor methods to get and set each of the data members.


3. Write a program with the Employee class that makes two Employees; 
sets their age, YearsOfService, and Salary; and prints their values.

 4. Continuing from Exercise 3, provide a method of Employee that reports how many 
 thousands of dollars the employee earns, rounded to the nearest 1,000.

 5. Change the Employee class so that you can initialize age, YearsOfService, and 
 Salary when you create the employee.
*/
#include <iostream.h>

class Employee {
	public:
		Employee (int NewAge, int NewYearsOfService, int NewSalary);
		int GetAge() const { return age; }
		int GetYearsOfService() const { return yearsOfService; }
		int GetSalary() const { return Salary; }
		void SetAge(int NewAge) { age = NewAge; }
		void SetYearsOfService(int NewYearsOfService) { yearsOfService = NewYearsOfService; }
		void SetSalary(int NewSalary) { Salary = NewSalary; }
		void RoundSalary();
	private:
		int age;
		int yearsOfService;
		int Salary;
};

Employee::Employee(int Newage, int NewYearsOfService, int NewSalary) {
	age = Newage;
	yearsOfService = NewYearsOfService;
	Salary = NewSalary;
}

void Employee::RoundSalary() {
	if ((Salary%1000)>=500) Salary = (Salary/1000)*1000+1000;
	else Salary = (Salary/1000)*1000;
}

int main() {
	Employee John(21,2,30000), Jim(30,5,50250);
	cout << "\nJohn's Age is: " << John.GetAge() << endl;
	cout << "\nJohn's Years of Service is: " << John.GetYearsOfService() << endl;
	cout << "\nJohn's Salary is: " << John.GetSalary() << endl;
	cout << "\nJim's Age is: " << Jim.GetAge() << endl;
	cout << "\nJim's Years of Service is: " << Jim.GetYearsOfService() << endl;
	cout << "\nJim's Salary is: " << Jim.GetSalary() << endl;
	Jim.RoundSalary();
	cout << "\nJim's Rounded Salary is: " << Jim.GetSalary() << endl;
	return 0;
}
